package com.moyq5.mvc.maker.test.bean.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

/**
 * 门店信息
 * @author Moyq5
 * @date 2018年4月13日
 */
@Entity
@Table(name = "uc_shop")
@DynamicUpdate
public class Shop implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1328702375449636788L;
	/**
	 * 门店ID
	 */
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "native")@GenericGenerator(name = "native", strategy = "native")
    @Column(name = "shop_id")
	private Long shopId;
	/**
	 * 商家
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "merch_id", nullable = false)
	private Merch merch;
	/**
	 * 门店名称
	 */
    @Column(name = "name", length = 100, nullable = false)
	private String name;
    /**
	 * 手机号
	 */
    @Column(name = "mobile", length = 20)
	private String mobile;
    /**
	 * 联系人
	 */
    @Column(name = "contacts", length = 20)
	private String contacts;
    /**
	 * 联系电话
	 */
    @Column(name = "tel", length = 20)
	private String tel;
    /**
	 * 门店地址
	 */
    @Column(name = "addr", length = 100)
	private String addr;
    /**
	 * 添加（注册）时间
	 */
	@Column(name = "add_time", nullable = false, columnDefinition="datetime")
	private Date addTime;
	
	@PrePersist
	public void prePersist() {
		if (null == addTime) {
			addTime = new Date();
		}
	}
	public Long getShopId() {
		return shopId;
	}
	public void setShopId(Long shopId) {
		this.shopId = shopId;
	}
	public Merch getMerch() {
		return merch;
	}
	public void setMerch(Merch merch) {
		this.merch = merch;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public Date getAddTime() {
		return addTime;
	}
	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}
	public String getAddr() {
		return addr;
	}
	public void setAddr(String addr) {
		this.addr = addr;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String getContacts() {
		return contacts;
	}
	public void setContacts(String contacts) {
		this.contacts = contacts;
	}
	
}
